<?php
//实现各种操作系统都能播放MPEG，AVI，WMV格式的视频
//抽象类,定义操作系统
abstract class OperationSystem{
     public $musicPattern;
     function playMpeg(){
            $this->musicPattern->playMpeg();
     }
     function playWmv(){
            $this->musicPattern->playWmv();
     }
     function playAvi(){
            $this->musicPattern->playAvi();
     }
}

//扩展抽象类，定义Linux的播放模式
class linux extends OperationSystem{
     function __construct(MusicPattern $musicPattern){
          $this->musicPattern = $musicPattern;
     }
}
//扩展抽象类，定义Linux的播放模式
class Windows extends OperationSystem{
     function __construct(MusicPattern $musicPattern){
          $this->musicPattern = $musicPattern;
     }
}
//扩展抽象类，定义Unix的播放模式
class Unix extends OperationSystem{
     function __construct(MusicPattern $musicPattern){
          $this->musicPattern = $musicPattern;
     }
}

//实现类接口
abstract class MusicParrenInterface{
    abstract function playMpeg();
    abstract function playWmv();
    abstract function playAvi();
}
//具体实现类
class MusicPattern extends MusicParrenInterface{
    function playMpeg(){
        echo "播放Mpeg格式的视频";
    }
    function playWmv(){
        echo "播放Wmv格式的视频";
    }
    function playAvi(){
        echo "播放Avi格式的视频";
    }

}


//测试
$operationSystem = new Windows(new MusicPattern());
$operationSystem->playMpeg();
echo "<br/>";
$operationSystem->playAvi();